#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int n;
    vector<int> nums;
    int temp;
    for (size_t i = 0; i < n; i++)
    {
        cin >> temp;
        nums.push_back(temp);
    }
    int res;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = i + 1; j < n; j++)
        {
            if (nums[i] > nums[j])
            {
                temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
                res += nums[j] - nums[i];
            }
        }
    }
}